#ifndef DEVICE_MANAGER_H
#define DEVICE_MANAGER_H
#include <QObject>

#include "DeviceHelper.h"

class DeviceManager : public QObject
{
    Q_OBJECT
public:
    static DeviceManager* instance();
    IDevice* getDeviceHelper(const QString& deviceName);
    void startAllDataMonitoring();
    void stopAllDataMonitoring();
    void stopAllDevices();

private:
    explicit DeviceManager(/* args */);
    ~DeviceManager();
    // 禁止拷贝和赋值
    DeviceManager(const DeviceManager&) = delete;
    DeviceManager& operator=(const DeviceManager&) = delete;

    QMap<QString, IDevice*> m_deviceHelpers;  // 设备助手列表，key为设备ID，value为设备助手对象
signals:
    void errorOccurred(const QString& deviceName, const QString& errorMessage);
    void commStatusChanged(const QString& deviceName, bool commStatus);
    void measurementOutOfRange(const QString& deviceName, float value, float lowerLimit,
                               float upperLimit);  // 测量值超出范围信号
};

#endif  // DEVICE_MANAGER_H
